package com.xrc.T2;

public class StudentBiz {
    private Student[] ss=new Student[10];
    private int size;
    public void addStudent(Student student){
        if(size<ss.length){
            ss[size++]=student;
        }


    }
    public void sortBYAge(){
        for (int i = 0; i < size-1; i++) {
            for (int j = 0; j < size-i-1; j++) {
                if(ss[j].getAge()>ss[j+1].getAge()){
                    Student temp=ss[j];
                    ss[j]=ss[j+1];
                    ss[j+1]=temp;
                }
            }
        }
    }
    public void sortBYScore(){
        for (int i = 0; i < size-1; i++) {
            for (int j = 0; j < size-i-1; j++) {
                if(ss[j].getScore()<ss[j+1].getScore()){
                    Student temp=ss[j];
                    ss[j]=ss[j+1];
                    ss[j+1]=temp;
                }
            }
        }
    }
    public void showStudent(){
        Student s;
        for (int i = 0; i < size; i++) {
            s=ss[i];
            System.out.println(s.getNO()+"\t"+s.getName()+"\t"+s.getAge()+"\t"+s.getScore()+"\t");
        }
    }
}
